package com.soushin.chinachess.widget;

import com.soushin.chinachess.R;
import com.soushin.chinachess.module.SettingsActivity;

import android.app.Activity;
import android.app.Dialog;
import android.content.Context;
import android.content.Intent;
import android.view.View;
import android.widget.TextView;
/**
 * 游戏页--选择弹出框
 * @author Administrator
 *
 */
public class SelecteDialog extends Dialog implements android.view.View.OnClickListener {

	private TextView tvSetting, tvExit, tvCancel;
	private Context context;
	public SelecteDialog(Context context) {
		super(context,R.style.myDialog);
		setContentView(R.layout.dialog_select);
		// TODO Auto-generated constructor stub
		initData();
		this.context=context;
	}

	private void initData() {
		// TODO Auto-generated method stub
		tvSetting = (TextView) findViewById(R.id.tv_setting);
		tvExit = (TextView) findViewById(R.id.tv_exit);
		tvCancel = (TextView) findViewById(R.id.tv_cancel);
		setCanceledOnTouchOutside(false);
		tvSetting.setOnClickListener(this);
		tvExit.setOnClickListener(this);
		tvCancel.setOnClickListener(this);
	}

	@Override
	public void onClick(View v) {
		// TODO Auto-generated method stub
		dismiss();//关闭弹出框
		switch (v.getId()) {
		case R.id.tv_setting:
			context.startActivity(new Intent(context,SettingsActivity.class));
			break;
		case R.id.tv_exit:
			((Activity) context).finish();//关闭界面
			System.exit(0);//从系统清除app
			break;
		case R.id.tv_cancel:
			break;

		}
	}

}
